<?php
$pathinfo = pathinfo(__FILE__);
preg_match('/.+(?=wp-content)/', $pathinfo['dirname'], $match);
$pathNeeded = preg_replace('/\ /', '/', $match[0]);
require_once($pathNeeded . 'wp-load.php'); //refer to wp-load to use instruction


if(isset($_GET['state']) && isset($_GET['country'])){    
    
    $idCountry = 0;
    $aResults = array();
    switch ($_GET['country']){
	case 'USA': $idCountry = 223;break;
	case 'India': $idCountry = 5;break;
	case 'Arab': $idCountry = 184;break;
    }        
    //get all state
    
    $aStates = Country::getStates($_GET['state'], $idCountry);    
    foreach($aStates as $state){
	$aResults[] = array('value' => $state->name,'label' => $state->name);
    }    							  
    echo json_encode($aResults);
    exit();
}

